~function (){
    function myCall(context){
        var arg=[]
         for(var i=1;i<arguments.length;i++){
             arg.push(arguments[i])
         }
        var result
        context.fn=this
        result=context.fn(...arg)
        delete context.fn
        return result
    }
    Function.prototype.myCall=myCall
}()
function add(a,b){
    return a+b;
}
function sub(a,b){
    return a-b;
}
var a1 = add.call(sub,4,2);
var a2 = add.myCall(sub,4,2);
console.log(a1)
console.log(a2)

~function (){
    function _call(obj){
        var args=[...arguments].slice(1)
        obj.term=this
        var reg= obj.term(...args)
        delete obj.term
        return reg
    }
    Function.prototype._call=_call
}()
var a3 = add._call(sub,4,2);
console.log(a3)
 // 手写bind
function bind1(asThis, ...args) {
  const fn = this; // 这里的 this 就是调用 bind 的函数 func
  return function (...args2) {
    return fn.apply(asThis, ...args, ...args2);
  };
}
